<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/8/30
  Time: 13:16
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="/script/layui/css/layui.css">
    <script type="text/javascript" src="/script/layui/layui.js"></script>
    <script type="text/javascript" src="/script/jquery-1.8.3.js"></script>
    <style>
        body {
            background-image: url("/image/beach.jpg");
            background-repeat: no-repeat;
            background-size: cover;
        }

        #left {
            margin-top: 50px;
            width: 200px;
            float: left;
        }

        #center {
            float: left;
            width: 1000px;
            margin-top: 40px;
            margin-left: 150px;
        }

        #title {
            font-size: 5em;
            color: white;
            text-align: center;

        }

        #body {
            overflow:hidden;
        }

        #top {
        }
    </style>
</head>
<body>
<div id="top">
    <ul class="layui-nav">
        <li class="layui-nav-item">
            <a href="">员工信息中心<%--<span class="layui-badge">9</span>--%></a>
        </li>
        <li class="layui-nav-item">
            <a href="">个人中心<span class="layui-badge-dot"></span></a>
        </li>
        <li class="layui-nav-item">
            <a href="javascript:void(0);"><img src="/image/timg.jpg" class="layui-nav-img">我</a>
            <dl class="layui-nav-child">
                <dd><a href="javascript:void(0);">当前用户:${sessionScope.admin.username}</a></dd>
                <dd><a href="javascript:void(0);">修改信息</a></dd>
                <dd><a href="javascript:void(0);">安全管理</a></dd>
                <dd><a href="admin_logout">退出</a></dd>
            </dl>
        </li>
    </ul>
</div>

<div id="title"><i>员工信息查询中心</i></div>

<div id="body">
    <div id="left">
        <ul class="layui-nav layui-nav-tree layui-bg-cyan" lay-filter="test">
            <li class="layui-nav-item layui-nav-itemed">
                <a href="javascript:;">员工中心</a>
                <dl class="layui-nav-child">
                    <dd id="empInfo"><a href="javascript:;">员工信息</a></dd>
                    <dd><a href="/out.jsp">员工论坛</a></dd>
                    <dd><a href="/out.jsp">员工服务</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item">
                <a href="/out.jsp">新闻查询</a>
                <dl class="layui-nav-child">
                    <dd><a href="">国际新闻</a></dd>
                    <dd><a href="">国内新闻</a></dd>
                    <dd><a href="/out.jsp">娱乐八卦</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item"><a href="">产品</a></li>
            <li class="layui-nav-item"><a href="">大数据</a></li>
        </ul>
    </div>
    <div id="center">
        <table class="layui-table" style="text-align: center">
            <colgroup>
                <col width="50">
                <col width="100">
                <col width="100">
                <col width="100">
                <col width="100">
                <col width="200">
            </colgroup>
            <thead>
            <tr>
                <th>编号</th>
                <th>员工姓名</th>
                <th>部门</th>
                <th>职务</th>
                <th>出生日期</th>
                <th>家庭地址</th>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td>贤心</td>
                <td>2016-11-29</td>
                <td>人生就像是一场修行</td>
                <td>人生就像是一场修行</td>
                <td>人生就像是一场修行</td>
                <td>人生就像是一场修行</td>
            </tr>
            </tbody>
        </table>
        <div id="demo1"></div>
    </div>
</div>

<table class="layui-hide" id="news"></table>


</body>
<script>
    var totalPage;
    var currPage;
    //注意：导航 依赖 element 模块，否则无法进行功能性操作

    $(function () {
        getAllNews();
       $("#empInfo").click(function () {
           getEmpInfo(currPage);
           layui.use(['element','laypage'], function () {
               var laypage = layui.laypage
               var element = layui.element;
               //总页数大于页码总数
               laypage.render({
                   elem: 'demo1'
                   ,count: totalPage*10 //数据总数
                   ,jump: function(obj){
                      getEmpInfo(obj.curr);
                   }
               });
           });
       })
    })

    function getEmpInfo(currPage) {
        $.ajax({
            type:"post",
            url:"emp_getEmpInfo",
            dataType:"JSON",
            async:false,
            data:{pageIndex:currPage||1},
            success:function (data) {
                totalPage = data.totalPages;
                var empList = data.empList;
                $(".emp").remove();
                $.each(empList,function (index,obj) {
                    var tr = "<tr class='emp'><td>"+(index+1)+"</td><td>"+obj.empname+"</td><td>"+obj.dept.deptname+"</td><td>"+obj.job+"</td><td>"+obj.hiredate+"</td><td>"+obj.dept.deptloc+"</td></tr>";
                    $(".layui-table").append(tr);
                });
            }
        });
    }


    function getAllNews() {
        layui.use('table', function(){
            var table = layui.table;
            table.render({
                elem: '#news'
                ,url:'news_getAllNews'
                ,cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
                ,cols: [[
                    {field:'id', width:80, title: 'ID', sort: true}
                    ,{field:'title', width:80, title: '新闻标题'}
                    ,{field:'context', width:80, title: '新闻内容'}
                    ,{field:'dateTime', width:80, title: '发布时间',sort:true}
                    ,{field:'sign', title: '签名', width: '30%', minWidth: 100} //minWidth：局部定义当前单元格的最小宽度，layui 2.2.1 新增
                    ,{field:'emp.empname', title: '发布人'}
                    ,{field:'score', title: '评分', sort: true}
                    ,{field:'classify', title: '职业'}
                    ,{field:'wealth', width:137, title: '财富', sort: true}
                ]]
            });
        });
    }
</script>
</html>
